package org.useCode.thread;


import com.google.common.util.concurrent.ThreadFactoryBuilder;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolInstance {

    private  ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("productDetail-pool-%d").build();
    private  ThreadPoolExecutor executorService = new ThreadPoolExecutor(11,
            32, 60,
            TimeUnit.SECONDS,
            new LinkedBlockingQueue(200),
            threadFactory, new ThreadPoolExecutor.AbortPolicy());

    private ThreadPoolInstance() {
    }
    private static final ThreadPoolInstance instance = new ThreadPoolInstance();

    public static ThreadPoolInstance getInstance() {
        return instance;
    }

    public ThreadPoolExecutor getExecutorService() {
        return executorService;
    }
}